package com.sxx.beautifulcity.activity;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.sxx.beautifulcity.R;
import com.sxx.beautifulcity.application.ProjectApplication;
import com.sxx.beautifulcity.toast.commcommonToast;
import com.sxx.beautifulcity.utils.NetWorkUtils;

/**
 * Created by dllo on 15/11/5.
 */
public class SetSoftActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView titleTv;
    private TextView moreTV;
    private ImageView backIv;
    private RelativeLayout clear_softRl , check_networkRl;
    private Toast toast;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_soft);
        initView();
    }

    private void initView() {
        titleTv = (TextView) findViewById(R.id.titleTv);
        titleTv.setText("设置");
        moreTV = (TextView) findViewById(R.id.moreTv);
        moreTV.setText("");
        backIv = (ImageView) findViewById(R.id.backIV);
        clear_softRl = (RelativeLayout) findViewById(R.id.clear_softRl);
        check_networkRl = (RelativeLayout) findViewById(R.id.check_networkRl);
        check_networkRl.setOnClickListener(this);
        clear_softRl.setOnClickListener(this);
        backIv.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.clear_softRl:
                final ProgressDialog progressDialog = new ProgressDialog(SetSoftActivity.this);
                progressDialog.setTitle("请求网络数据");
                progressDialog.setMessage("数据读取中...");
                progressDialog.show();
                final Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        progressDialog.dismiss();

                    }
                });thread.start();

                progressDialog.dismiss();
                break;
            case R.id.backIV:
                Intent intent = new Intent(ProjectApplication.getContext(), MainActivity.class);
                startActivity(intent);
                finish();
                overridePendingTransition(R.anim.left_out, R.anim.right_into);
                break;
            case R.id.check_networkRl:
                boolean checknet = NetWorkUtils.checkNet(this);
                if (checknet == true) {
                   commcommonToast.successToast();
                }
                else{
                   commcommonToast.failToast();
                }
                break;
        }
    }
}
